package com.fifth.home.controller;

import com.fifth.common.pojo.dto.CommonResult;
import com.fifth.common.pojo.entity.HeadNav;
import com.fifth.home.pojo.vo.FuzzySearch;
import com.fifth.home.service.IHeadNavService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 第五组
 * @since 2022-09-01
 */
@RestController
@RequestMapping("/home/headNav")
@Api(tags = "头部导航相关接口")
public class HeadNavController {
    @Autowired
    private IHeadNavService headNavService;

    /**
     * 前端头部导航
     * @return
     */
    @ApiOperation("查询前端头部导航接口(前端调用)")
    @GetMapping("headNavigation")
    public CommonResult headNavigation(){
        return headNavService.navigation();
    }

    /**
     * 后端头部导航  模糊查询
     * @param fuzzySearch
     * @return
     */
    @ApiOperation("查询后台头部导航接口")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "furrySearch",value = "furrySearch实体类",dataType = "FurrySearch"),
                    @ApiImplicitParam(name = "currentPage",value = "当前页码",dataType = "int"),
                    @ApiImplicitParam(name = "pageSize",value = "每页条数",dataType = "int")
            }
    )
    @PostMapping("fuzzySearch")
    public CommonResult fuzzySearch(@RequestBody FuzzySearch fuzzySearch,@RequestParam(defaultValue = "1") Integer currentPage,@RequestParam(defaultValue = "5") Integer pageSize){
        return headNavService.fuzzyQuery(fuzzySearch,currentPage,pageSize);
    }

    /**
     * 添加导航回显    添加导航需要传 1
     * @return
     */
    @ApiOperation("添加头部导航回显接口")
    @GetMapping("navigationSearch")
    public CommonResult navigationSearch(){
        return headNavService.navigationQuery();
    }

    /**
     * 添加导航
     * @param fuzzySearch
     * @return
     */
    @ApiOperation("添加后台头部导航接口")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "furrySearch",value = "furrySearch实体类",dataType = "FurrySearch")
            }
    )
    @PostMapping("insertNavigation")
    public CommonResult insertNavigation(@RequestBody FuzzySearch fuzzySearch){
        return headNavService.addNavigation(fuzzySearch);
    }

    /**
     * 修改导航 标题状态  0正常  1禁用
     * @param
     * @return
     */
    @ApiOperation("修改后台头部导航状态接口")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "headId",value = "头部导航id",dataType = "String"),
                    @ApiImplicitParam(name = "isDisable",value = "状态 0启动 1禁用",dataType = "String")
            }
    )
    @PostMapping("updateDisable/{headId}/{isDisable}")
    public CommonResult updateDisable(@PathVariable String headId,@PathVariable String isDisable){
        return headNavService.updateStatus(headId,isDisable);
    }

    /**
     * 删除导航   逻辑删除
     * @param headId
     * @return
     */
    @ApiOperation("删除后台头部导航接口")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "headId",value = "头部导航id",dataType = "String")
            }
    )
    @GetMapping("removeNavigation")
    public CommonResult removeNavigation(@RequestParam String headId){
        return headNavService.deleteNavigation(headId);
    }

    /**
     * 修改导航信息
     * @param fuzzySearch
     * @return
     */
    @ApiOperation("修改后台头部导航信息接口")
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "furrySearch",value = "furrySearch实体类",dataType = "FurrySearch")
            }
    )
    @PostMapping("updateNavigation")
    public CommonResult updateNavigation(@RequestBody FuzzySearch fuzzySearch){
        return headNavService.updateNavigationDetails(fuzzySearch);
    }


}
